/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.on.clinical.presenter;

import com.on.clinical.view.ViewTelaPrincipal;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import javax.swing.JOptionPane;

/**
 *
 * @author Raphael
 */
public class PresenterTelaPrincipal {

    private ViewTelaPrincipal view;

    public PresenterTelaPrincipal(String tipo) {
        view = new ViewTelaPrincipal(null, true);

        view.getMenuSair().addActionListener(new ActionListener() {
            @Override
            public void actionPerformed(ActionEvent e) {
                sair();
            }
        });
        
        view.getMenuInformacao().addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                informacoes();
            }
        });
        
        nivelAcesso(tipo);
        posicionaLogo();
        view.setSize(redimensionarView());
        view.setLocationRelativeTo(view);
        view.setVisible(true);

    }
    
    public void informacoes(){
        new PresenterTelaInformacoesClinica();
    }

    public void nivelAcesso(String tipo) {
        if (tipo.equals("Médico")) {
        } else if (tipo.equals("Funcionário")) {
        }

    }

    public void posicionaLogo() {
        int w = (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth();
        int h = (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight();
        
        view.getLogoClinical().setLocation(w-290, h-125);
    }

    public Dimension redimensionarView() {  //Redimencionamento da tela
        return (new Dimension(
                (int) Toolkit.getDefaultToolkit().getScreenSize().getWidth(),
                (int) Toolkit.getDefaultToolkit().getScreenSize().getHeight()));

    }

    public void sair() {
        view.dispose();
        new PresenterTelaAutenticacao();
    }
}
